﻿<div ng-controller="OrderBaseEditC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">修改客户基本信息</h1>
    </div>
    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="form-group">
                                <label>客户</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Customer.Name}}">
                            </div>
                            <div class="form-group">
                                <label>公司户头</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Account.Name}}">
                            </div>
                            <div class="form-group">
                                <label>仓库</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Provider.Name}}">
                            </div>
                            <div class="form-group">
                                <label>区域</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.District.FillName}}">
                            </div>
                            <div class="form-group">
                                <label>具体地址</label>
                                <input ng-model="orderdetaildata.Address" type="text" class="form-control">
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label style="margin-right: 10px;">是否先款</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsFullPayment">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <!--<div class="form-group">-->
                                <!--<label style="margin-right: 10px;">是否锁价</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsLockPrice">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <!--<div class="form-group">-->
                                <!--<label style="margin-right: 10px;">是否标件</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsStandard">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <!--<div class="form-group">-->
                                <!--<label style="margin-right: 10px;">是否送货</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsDelivery">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <div class="form-group">
                                <label for="xiankuan" style="margin-right: 10px;">是否先款</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="xiankuan" disabled="disabled" ng-model="orderdetaildata.IsFullPayment">
                                    <i></i>
                                </label>
                                <label for="suojia" style="margin-right: 10px;">是否锁价</label>
                                <label class="i-checks">
                                    <input class="changeprice" id="suojia"  disabled="disabled" type="checkbox" ng-model="orderdetaildata.IsLockPrice">
                                    <i></i>
                                </label>
                            </div>
                            <div class="form-group">
                                <label for="biaojian" style="margin-right: 10px;">是否标件</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="biaojian" disabled="disabled" ng-model="orderdetaildata.IsStandard">
                                    <i></i>
                                </label>
                                <label for="songhuo" style="margin-right: 10px;">是否送货</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="songhuo" disabled="disabled" ng-model="orderdetaildata.IsDelivery">
                                    <i></i>
                                </label>
                            </div>
                            <div class="form-group" ng-if="orderdetaildata.IsDelivery">
                                <label style="margin-right: 10px;">运费是否公户</label>
                                <label class="i-checks">
                                    <input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsPublicDelivery">
                                    <i></i>
                                </label>
                            </div>
                            <div class="form-group" ng-if="orderdetaildata.IsDelivery">
                                <label>每吨运费</label>
                                <input ng-model="orderdetaildata.DeliveryPrice" type="number" min="0" class="form-control" required>
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>车辆信息(每条信息以英文逗号分隔)</label>
                                <input type="text" ng-pattern="/^[a-zA-Z0-9\u4e00-\u9fa5,]+$/" class="form-control" ng-model="orderdetaildata.VehicleInfos">
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>联系人(每条信息以英文逗号分隔)</label>
                                <input type="text" ng-pattern="/^[a-zA-Z0-9\u4e00-\u9fa5,]+$/" class="form-control" ng-model="orderdetaildata.Contact">
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>联系人手机号(每条信息以英文逗号分隔)</label>
                                <input type="text" ng-pattern="/^[0-9,]+$/" class="form-control" ng-model="orderdetaildata.ContactPhone">
                            </div>
                            <div class="form-group">
                                <label>备注</label>
                                <input ng-model="orderdetaildata.Remarks" type="text" class="form-control" placeholder="请输入备注信息（100字内）" maxlength="100">
                            </div>
                            <!--<div class="form-group">
                                <label>申请单价优惠</label>
                                <input ng-model="orderdata.ApplyDiscount" type="number" class="form-control" required>
                            </div>
                            <div class="form-group">
                                <label>申请总价优惠</label>
                                <input ng-model="orderdata.BargainingAmount" type="number" class="form-control" required>
                            </div>-->
                            <div class="row text-right">
                                <button type="button" class="btn btn-success" ng-click="okchange()">确认更改</button>

                                <button type="button" class="btn btn-default" ng-click="cancelchange()">取消更改</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')
        //更改计划单用户信息控制器
    .controller("OrderBaseEditC", function ($scope, $state, $stateParams, $http) {
        $scope.id = JSON.parse($stateParams.orderid);
        //获取计划单详细数据
        $http({
            url: "../api/Order/Detail?id=" + $scope.id,
            method: "GET"
        })
            .then(function (res) {
                $scope.orderdetaildata = res.data;
            })
            .then(function (error) {
                if (error) {
                    console.log("error");
                }
            });
        //保存用户信息
        $scope.okchange = function () {
            $http.post('../api/OrderManager/OrderBaseEdit', $scope.orderdetaildata)
                .success(function (res) {
                    if (res.State <= 0) {
                        alert(res.Msg);
                    } else {
                        alert("添加成功");
                        $state.go('app.Order_Detail', {
                            orderid: JSON.stringify($scope.id)
                        });
                    }

                });
        };
        //取消更改
        $scope.cancelchange = function () {
            $state.go('app.Order_Detail', {
                orderid: JSON.stringify($scope.id)
            });
        }
    })
</script>